//
//  UserInfoViewController.m
//  wsgz
//
//  Created by huck on 2017/5/12.
//  Copyright © 2017年 BoingPay. All rights reserved.
//

#import "UserInfoViewController.h"
#import "AppUtils.h"

@interface UserInfoViewController ()

@end

@implementation UserInfoViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    [self initSubview];
}

-(void)initSubview
{
    _versionLabel.text = [NSString stringWithFormat:@"APP版本信息:V%@",[AppUtils currentVersion]];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self initUserInfo];
}

-(void)initUserInfo
{
    _titleName.text = nil;
    _nameLabel.text = nil;
    _userNameLabel.text = nil;
    _userRoleLabel.text = nil;
    _loginoutBtn.hidden = YES;
    _areaLabel.text = nil;
    _view1.hidden = YES;
    _view2.hidden = YES;
    _titleName.text = @"未登录";
    if ([AppUtils isLogin]) {
        _view1.hidden = NO;
        _view2.hidden = NO;
        _titleName.text = LOGIN_USER.name;
        _nameLabel.text = LOGIN_USER.name;
        _userNameLabel.text = LOGIN_USER.userName;
        NSMutableArray *arr= [NSMutableArray array];
        if([AppUtils isNotEmptyArray:LOGIN_USER.roleList]) {
            for(RoleInfoData *role in LOGIN_USER.roleList) {
                [arr addObject:role.roleName];
            }
        }
        _userRoleLabel.text = [AppUtils joinArray:arr];
        _areaLabel.text = LOGIN_USER.beregion;
        _loginoutBtn.hidden = NO;
    }
}


- (IBAction)logoutBtnClick:(UIButton *)sender
{
    [[LoginDataMng sharedInstance] loginOut];
}
@end
